<include file="public/header" />
 <link rel="stylesheet"  href="__ADMIN__/css/global.css">
 <link rel="stylesheet"  href="__ADMIN__/css/master.css"   type="text/css" />
 <link rel="stylesheet"  href="__ADMIN__/css/jquery.treeTable.css"  type="text/css" />
</head>
<body style="background: #fff;">
<div class="layui-field-box">
		<blockquote class="layui-elem-quote">
			<div class="layui-inline fr" >
				<button class="layui-btn layui-btn-normal" id="refresh_wrapper">
					<i class="layui-icon">&#x1002;</i>
				</button>
			</div>
			<div class="layui-inline mb10 fr mr10">
		    	<a onclick="iframe('{:url('System/addressaddedit')}','添加地区信息','500px','230px')"   class="layui-btn layui-btn-danger">
					<i class="layui-icon">&#xe608;</i>&nbsp;&nbsp;添加地区信息
				</a>
			</div>
			<div class="clear"></div>
		</blockquote>

  <form class="layui-form">
    <table id="dnd-example" class="site-table">
	      <thead>
		        <tr>
		          <th style="text-align: center; width:20%">地区编号</th>
		          <th style="text-align: center;">地区名称</th>
		          <th style="text-align: center;">显示/隐藏</th>
		          <th style="text-align: center; width:250px">选择操作</th>
		        </tr>
	      </thead>
	      <tbody>
	     		 {$categorys}
	      </tbody>
    </table>
  </form>
 	<if condition="$allpage gt 1">
		<div class="admin-table-page">
			<div id="mylaypage" ></div>
		</div>
	 </if> 
</div>
 <script>
  	myjumppage = "{:url('System/address',['page'=>'pageval','limits'=>'limitval'])}";
  </script>
  <include file="public/footer" />
  <script src="__ADMIN__/js/jquery.treeTable.js" 					type="text/javascript" ></script>
  <script type="text/javascript">
  $(document).ready(function() {
    $("#dnd-example").treeTable();
    
    $("#dnd-example .folder").each(function() {
      $($(this).parents("tr")[0]).droppable({
        accept: ".file, .folder",
        drop: function(e, ui) {
          $($(ui.draggable).parents("tr")[0]).appendBranchTo(this);
        },
        hoverClass: "accept",
        over: function(e, ui) {
          if(this.id != ui.draggable.parents("tr.parent")[0].id && !$(this).is(".expanded")) {
            $(this).expand();
          }
        }
      });
    });
    
    $("table#dnd-example tbody tr").mousedown(function() {
      $("tr.selected").removeClass("selected"); // Deselect currently selected rows
      $(this).addClass("selected");
    });
    $("table#dnd-example tbody tr span").mousedown(function() {
      $($(this).parents("tr")[0]).trigger("mousedown");
    });
  });
  </script>
<script>
	form.render();
	//监听switch
	form.on('switch(category)', function(data) {
		var url=$(data.elem).attr("data-action");
		var id = data.elem.id;
		$.getJSON(url,function(result){
			if(result.code == 1){
				layer.msg(result.msg);
			}else if(result.code == 0){
				 	$("#"+id).removeAttr("checked")
					$("#"+id).next().removeClass("layui-form-onswitch");
				 	layer.msg(result.msg);
			}else if(result.code == 2){
					layer.alert(result.msg,{
                        closeBtn: 0,
						btn: ['确认'],
					}, function() {
						reloadPage(window);
					});
			}
		});
	});
</script>
</body>
</html>